package com.sj.purchase.modules.purchase.repository;

import com.sj.purchase.modules.purchase.domain.StockPrice;
import com.sj.purchase.modules.cost.views.VshSales;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;

/**
 * Created by 宋开宗 on 2017/6/24 0024.
 */
public interface StockPriceRepository extends JpaRepository<StockPrice, Long> {
    /**
     * 查询上海仓销量
     *
     * @param day
     * @param pageable
     * @return
     */
    @Query(value = "select  new com.sj.purchase.modules.cost.views.VshSales(s.gySpu.id,sp.purchase.id.skuNo,s.name,sp.yesterdaySales) from StockPrice sp,GySku s where sp.purchase.id.skuNo=s.id and sp.warehouseEnum='SHANGHAI' and sp.purchase.id.createDate=?1")
    Page<VshSales> findShSales(Date day, Pageable pageable);
}
